/**
 * Copyright &copy; 2012-2016 <a href="https://istep.lczyfz.com">Istep</a> All rights reserved.
 */
package com.lczyfz.istep.modules.resource.service;

import java.util.List;

import com.lczyfz.istep.common.constants.DeleteFlag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lczyfz.istep.common.persistence.Page;
import com.lczyfz.istep.common.service.CrudService;
import com.lczyfz.istep.modules.resource.entity.ResourceCourse;
import com.lczyfz.istep.modules.resource.dao.ResourceCourseDao;

/**
 * 课程管理Service
 * @author dh
 * @version 2017-01-16
 */
@Service
@Transactional(readOnly = true)
public class ResourceCourseService extends CrudService<ResourceCourseDao, ResourceCourse> {

	@Autowired
	ResourceCourseDao resourceCourseDao;

	public ResourceCourse get(String id) {
		return super.get(id);
	}
	
	public List<ResourceCourse> findList(ResourceCourse resourceCourse) {
		return super.findList(resourceCourse);
	}
	
	public Page<ResourceCourse> findPage(Page<ResourceCourse> page, ResourceCourse resourceCourse) {
		return super.findPage(page, resourceCourse);
	}
	
	@Transactional(readOnly = false)
	public void save(ResourceCourse resourceCourse) {
		super.save(resourceCourse);
	}
	
	@Transactional(readOnly = false)
	public void delete(ResourceCourse resourceCourse) {
		super.delete(resourceCourse);
	}

	public ResourceCourse findCourseByCourseName(ResourceCourse resourceCourse) {
		return dao.findCourseByCourseName(resourceCourse);
	}
	@Transactional(readOnly = false)
	public void insert(ResourceCourse resourceCourse) {
		dao.insert(resourceCourse);
	}

	//课程体系链接查看课程
	public Page<ResourceCourse> viewCourseList(Page<ResourceCourse> page, ResourceCourse resourceCourse) {
		logger.debug("==Evan==viewCourseListService=="+resourceCourse.getCourseSystemId());
		resourceCourse.setPage(page);
		page.setList(dao.viewCourseList(resourceCourse));
		return page;
	}
	/**
	 *根据课程体系id查询课程列表
	 * @param page
	 * @param resourceCourse
	 * @return
	 */
	public Page<ResourceCourse> findPageByCoursesystemId(Page<ResourceCourse> page, ResourceCourse resourceCourse) {
		resourceCourse.setPage(page);
		page.setList(dao.findCourseListByCoursesystemId(resourceCourse));
		return page;
	}

	//我的课程-课程列表展示
	public Page<ResourceCourse> stuCourseList(Page<ResourceCourse> page, ResourceCourse resourceCourse) {
		resourceCourse.setPage(page);
		page.setList(resourceCourseDao.stuCourseList(resourceCourse));
		return page;
	}

	//我的学习任务-获取课程名称
	public List<ResourceCourse> stuLearnCourse(String distributeId, String userId){
		return resourceCourseDao.stuLearnCourse(distributeId, userId, DeleteFlag.deleteFlag);
	}

}